const {merge} =require('webpack-merge');
const baseConfig =require('./webpack.base.js');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
module.exports=merge(baseConfig,{
  mode: 'production',
  optimization: {
    minimizer: [
      `...`,
      new CssMinimizerPlugin(),
    ],
    // chunkIds:'natural',
    splitChunks: {
      maxSize:100*1024,
      chunks: "all",
      // 重复打包问题
      cacheGroups: {
        vendors: {
          chunks: "all",
          // name: 'vendors', 一定不要定义固定的name
          priority: 10, // 优先级
          enforce: true,
        },
      },
    },
  },
  output:{
    clean: true,
  },
  plugins:[
    new MiniCssExtractPlugin({
      filename: "css/[name].[contenthash:8].css",
      chunkFilename: "css/[contenthash:8].css",
      ignoreOrder: true,
    }),
  ]
})